package com.ksd1.notes.markdown.parser;

import com.ksd1.notes.markdown.Markdown;
import com.ksd1.notes.markdown.Markdown.MDParser;
import com.ksd1.notes.markdown.Markdown.MDWord;

public class HeaderParser extends MDParser {

    public static final String HEADER = "# ";
    public static final String HEADER2 = "## ";
    public static final String HEADER3 = "### ";

    /**
     * 标题进行行的格式化
     * @param content 格式化内容
     * @return MDWord
     */
    @Override
    public MDWord parseLineFmt(String content) {
        if (content.startsWith(HEADER)) {
            return new MDWord("", HEADER.length(), Markdown.MD_FMT_HEADER1);
        } else if (content.startsWith(HEADER2)) {
            return new MDWord("", HEADER2.length(), Markdown.MD_FMT_HEADER2);
        } else if (content.startsWith(HEADER3)) {
            return new MDWord("", HEADER3.length(), Markdown.MD_FMT_HEADER3);
        }
        return MDWord.NULL;
    }

    /**
     * 标题不进行词的格式化
     * @param content  格式化内容
     * @return NULL
     */
    @Override
    public MDWord parseWordFmt(String content) {
        return MDWord.NULL;
    }
}
